package com.ostrich.cloud.ostrichUserService.infra.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ostrich.cloud.ostrichUserService.infra.model.Rider;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ostrich.ostrichUserService.dto.RiderDto;
import org.apache.ibatis.annotations.*;

/**
 * <p>
 * 骑手表 Mapper 接口
 * </p>
 *
 * @author Lucas
 * @since 2022-10-26
 */
public interface RiderMapper extends BaseMapper<Rider> {

    @Select("<script>"+
            "SELECT * " +
            "from rider" +
            "<where>" +
            "<if test='status != null and status.trim() != &quot;&quot;'>" +
            "and rider_status = #{status}" +
            "</if>" +
            "<if test='businessmanId != null'>" +
            "and businessman_id = #{businessmanId}" +
            "</if>" +
            "</where>" +
            "</script>")
    @Results(id="get",value = {
            @Result(property = "riderId",column = "rider_id",id = true),
            @Result(property = "userParent",column = "parent_id",one = @One(
                    select = "com.ostrich.cloud.ostrichUserService.infra.mapper.CustomerMapper.getUserParentById"
            ))
    })
    IPage<RiderDto> getSAllRider(Page<RiderDto> page, @Param("status") String status,@Param("businessmanId") Integer businessmanId);
}
